package edu.mapi.aamas.common;

import java.io.Serializable;
import java.util.Vector;

import javax.vecmath.Point3d;

/**
 * @author ZP
 */
public class Task implements Serializable {
	private String id;
	private Vector<Point3d> points = new Vector<Point3d>();
	private int currentPoint = 0;
	
	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}
	/**
	 * @return the points
	 */
	public Vector<Point3d> getPoints() {
		return points;
	}
	/**
	 * @param points the points to set
	 */
	public void setPoints(Vector<Point3d> points) {
		this.points = points;
	}
	
	/**
	 * Adds a point to this task's trajectory
	 * @param point The point to be added
	 */
	public void addPoint(Point3d point) {
		points.add(new Point3d(point));
	}
	
	/**
	 * Creates a one point trajectory/task
	 * @param id The id of the Task
	 * @param point The destination
	 * @return The created task
	 */
	public Task createGoto(String id, Point3d point) {
		Task task = new Task();
		task.id = id;
		task.addPoint(point);
		return task;
	}
	
	public Point3d getLastPoint() {
		return getPoints().lastElement();
	}
	/**
	 * @return the currentPoint
	 */
	public int getCurrentPoint() {
		return currentPoint;
	}
	/**
	 * @param currentPoint the currentPoint to set
	 */
	public void setCurrentPoint(int currentPoint) {
		this.currentPoint = currentPoint;
	}
	
	@Override
	public String toString() {
		return "Goto ("+((int)points.get(0).x)+", "+((int)points.get(0).y)+")";
	}
}
